#ifndef __LDC100_H_
#define __LDC1000_H_
#include "stm32f10x.h"
#define REG_LEN					20

#define RPMIN 					0x3A
#define RPMAX 					0x13

// LDC COMMANDS
#define LDC1000_CMD_REVID 		0x00
#define LDC1000_CMD_RPMAX 		0x01
#define LDC1000_CMD_RPMIN 		0x02
#define LDC1000_CMD_SENSORFREQ 	0x03
#define LDC1000_CMD_LDCCONFIG 	0x04
#define LDC1000_CMD_CLKCONFIG 	0x05
#define LDC1000_CMD_THRESHILSB 	0x06
#define LDC1000_CMD_THRESHIMSB 	0x07
#define LDC1000_CMD_THRESLOLSB 	0x08
#define LDC1000_CMD_THRESLOMSB 	0x09
#define LDC1000_CMD_INTCONFIG 	0x0A
#define LDC1000_CMD_PWRCONFIG 	0x0B
#define LDC1000_CMD_STATUS	 	0x20
#define LDC1000_CMD_PROXLSB 	0x21
#define LDC1000_CMD_PROXMSB 	0x22
#define LDC1000_CMD_FREQCTRLSB	0x23
#define LDC1000_CMD_FREQCTRMID	0x24
#define LDC1000_CMD_FREQCTRMSB	0x25

// LDC BITMASKS
#define LDC1000_BIT_AMPLITUDE    0x18
#define LDC1000_BIT_RESPTIME     0x07
#define LDC1000_BIT_CLKSEL       0x02
#define LDC1000_BIT_CLKPD        0x01
#define LDC1000_BIT_INTMODE      0x07
#define LDC1000_BIT_PWRMODE      0x01
#define LDC1000_BIT_STATUSOSC    0x80
#define LDC1000_BIT_STATUSDRDYB  0x40
#define LDC1000_BIT_STATUSWAKEUP 0x20
#define LDC1000_BIT_STATUSCOMP   0x10





void 	LDC1000_GPIO_Init(void);
void 	LDC1000_SPI_Init(void);
void 	LDC1000_Init(void);
void 	LDC1000_WriteReg(uint8_t addr, uint8_t dat);
uint8_t LDC1000_SendByte(uint8_t dat);
//uint8_t 	LDC1000_ReadBytes(uint8_t addr, uint8_t *pBuffer, uint8_t len);
uint8_t LDC1000_ReadBytes(uint8_t addr, uint8_t Buffer[], uint8_t len);
uint8_t LDC1000_ReadByte(void);

uint8_t LDC1000_ReadReg(uint8_t addr);
void LDC1000_TbclkInit(void);
void LDC1000_INT_Init(void);

extern int8_t proximtyData[2];
extern int8_t frequencyData[3];

extern int16_t proximtyDataMIN;
extern int16_t frequencyDataMIN;

extern int16_t proximtyDataMAX;
extern int16_t frequencyDataMAX;

extern int16_t proximtyDataTEMP;
extern int16_t frequencyDataTEMP;
extern uint8_t orgVal[12];

extern  int16_t proximtySum, proximtyNew, proximtyOld;
extern  int16_t frequencySum, frequencyNew, frequencyOld;



#endif /* LDC1000_CMD_H_ */

/** @} */
